package com.yejign.quartzdemo;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

public class Demo2 {
    public static void main(String[] args) throws Exception{

        JobDetail jobDetail = JobBuilder.newJob(TestJob3.class)
                .usingJobData("executeCount",0)
                .withIdentity("testJob3", "testJob3Group")
                .build();

        Trigger trigger = TriggerBuilder.newTrigger()
                .withIdentity("testTrigger", "testTriggerGroup")
                .startNow()
                .withSchedule(SimpleScheduleBuilder.repeatSecondlyForever(5))
                .build();

        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
        scheduler.scheduleJob(jobDetail, trigger);

        // 5，开启任务
        scheduler.start();
    }
}
